home *** CD-ROM | disk | FTP | other *** search
/ Turnbull China Bikeride / Turnbull China Bikeride - Disc 2.iso / STUTTGART / FROMUTS / UNIXLIB37B / src / unix / c / gethostnam < prev    next >
Text File  |  1990-09-28  |  527b  |  30 lines

  1. static char sccs_id[] = "@(#) gethostname.c 1.2 "__DATE__" HJR";
  2.  
  3. /* gethostname.c (c) Copyright 1990 H.Rogers */
  4.  
  5. #include <string.h>
  6. #include <errno.h>
  7.  
  8. #include "sys/unix.h"
  9. #include "sys/os.h"
  10.  
  11. /* gethostname() returns "acorn<station>" */
  12.  
  13. char *gethostname(void)
  14. {
  15. int r[3];
  16. os_error *e;
  17. static char buf[8];
  18. static char hex[16] = "0123456789abcdef";
  19.  
  20. strcpy(buf,"acorn");
  21. if (e = os_byte(0xa1,0,0,r))
  22.   {
  23.   __seterr(e);
  24.   return(0);
  25.   }
  26. buf[7] = 0; buf[6] = hex[r[1] & 0xf]; buf[5] = hex[(r[1]>>4) & 0xf];
  27.  
  28. return(buf);
  29. }
  30.